package com.xuecheng.media.api;

import com.adan.base.model.RestResponse;
import com.xuecheng.media.model.po.MediaFiles;
import com.xuecheng.media.service.MediaFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @version: 1.0
 * @Author: adan
 * @description: 获取视频地址
 * @date: 2023-06-20 22:54
 */
@Slf4j
@RestController
@RequestMapping("/open")
public class MediaOpenController {
    @Resource
    private MediaFileService mediaFileService;

    @GetMapping("/preview/{mediaId}")
    public RestResponse<String> getMediaUrl(@PathVariable String mediaId) {
        MediaFiles mediaFile = mediaFileService.getPlayUrlByMediaId(mediaId);
        return RestResponse.success(mediaFile.getUrl());
    }
}
